import java.util.concurrent.atomic.AtomicInteger;

/**
 * @version 1.8
 * @Author Djx_hmbb
 * @Date 2023/8/22 17:48
 * @注释:CAS
 */
public class ThreadDemo25 {
    public static void main(String[] args) {
        AtomicInteger count = new AtomicInteger();
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 500; i++) {
                count.getAndIncrement();
            }
        });

        Thread t2 = new Thread(()->{
            for (int i = 0; i < 500; i++) {
                count.getAndIncrement();
            }
        });

        t1.start();
        t2.start();
        t1.run();
        t2.run();
        System.out.println(count);
    }
}
